package com.sxu.spring_ioc;

import com.sxu.spring_ioc.controller.HelloController;
import com.sxu.spring_ioc.controller.UserController;
import com.sxu.spring_ioc.model.UserInfo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringIocApplication {

    public static void main(String[] args) {
        //Application-应用  Context-上下文
        ApplicationContext context = SpringApplication.run(SpringIocApplication.class, args);
        UserController bean = context.getBean(UserController.class);
        bean.sayHi();

//
//        //返回值为Object类型 需要强转
//        HelloController helloController = (HelloController) context.getBean("helloController");
//        helloController.sayHi();
//
//        HelloController helloController1 = context.getBean("helloController", HelloController.class);
//        helloController1.sayHi();
//
//        System.out.println(bean);
//        System.out.println(helloController);
//        System.out.println(helloController1);
//
//        UserInfo bean = (UserInfo) context.getBean("userInfo");
//        System.out.println(bean);
//        UserInfo bean1 = (UserInfo) context.getBean("userInfo1");
//        System.out.println(bean);
//        UserInfo bean2 = (UserInfo) context.getBean("USERInfo");
//        System.out.println(bean);
    }

}

